package com.qzimp.fujiancuo.controller;

import com.qzimp.fujiancuo.entity.Culture;
import com.qzimp.fujiancuo.service.CultureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cultures")
public class CultureController {

    @Autowired
    private CultureService cultureService;

    @GetMapping("/temple/{templeId}")
    public List<Culture> getCulturesByTempleId(@PathVariable Long templeId) {
        return cultureService.findByTempleId(templeId);
    }

    @PostMapping
    public void addCulture(@RequestBody Culture culture) {
        cultureService.addCulture(culture);
    }

    @PutMapping
    public void updateCulture(@RequestBody Culture culture) {
        cultureService.updateCulture(culture);
    }

    @DeleteMapping("/{id}")
    public void deleteCulture(@PathVariable Long id) {
        cultureService.deleteCulture(id);
    }
}